<div class="box">
    <div class="heading">
        <h1><img alt="" src="<?php echo base_url('assets/admin/images/layout.png'); ?>">Gallery</h1>

        <div class="buttons">
            <a class="button" href="<?php echo base_url(ADMIN_PATH . "/gallery/addgallery"); ?>"><span>Add Gallery</span></a>
            <a class="button delete" href="#"><span>Delete</span></a>
        </div>
    </div>
    <div class="content">
		  
        <?php echo form_open(null, 'id="form"'); ?>
            <table class="list">
                <thead>
                    <tr>
                        <th width="1" class="center"><input type="checkbox" onClick="$('input[name*=\'selected\']').attr('checked', this.checked);" /></th>
                        <th>Title</th>
                        <th>Short Name</th>
						<th>Gallery Short Code</th>
						<th>Gallery Page Short Code</th>
                        <th class="right">Action</th>
                    </tr>
                </thead>
                <tbody>
					 
                     <?php if ($galleries):?>
                        <?php foreach($galleries as $gallery): ?>
							
                        <tr class="tr_link">
                            <td class="center"><input type="checkbox" value="<?php echo $gallery['id']; ?>" name="selected[]" /></td>
                            <td><?php echo $gallery['title']; ?></td>
                            <td><?php echo $gallery['short_name']; ?></td>
							<td><?php highlight_string('<?php echo $this->template->widget("dynamic_widget", array("short_name"=>"'.$gallery['short_name'].'","widget_type"=>"'.$gallery['widget_type'].'")); ?>');?></td>
							
							<td><?php highlight_string('[galleries id='.$gallery['id'].']');?></td>
                            <td class="right">
								[ <a class="rename" href="<?php echo base_url(ADMIN_PATH . '/gallery/editgallery/' . $gallery['id']); ?>">Rename</a> ]
                                [ <a href="<?php echo base_url(ADMIN_PATH . '/gallery/images/'.$gallery['id']); ?>">Edit</a> ]
							</td>
                        </tr>
                        <?php endforeach; ?>
                    <?php else: ?>
                        <tr>
                            <td class="center" colspan="5">No Widgets have been added.</td>
                        </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        <?php echo form_close(); ?>

    </div>
</div>
<script type="text/javascript">
$(document).ready(function() {
// Delete
	$('.delete').click( function() {
		if (confirm('Delete cannot be undone! Images will remain on the server. Are you sure you want to do this?'))
		{
			$('#form').attr('action', '<?php echo base_url(ADMIN_PATH . '/gallery/deletegallery/'); ?>').submit()
		}
		else
		{
			return false;
		}
	});
});
</script>
